<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //构造函数语法格式
        //构造函数首字母大写
        // function Star(uname, age, sex) {
        //     this.uname = uname;
        //     this.age = age;
        //     this.sex = sex;
        //     this.sing = function(sang) {
        //         console.log(sang);
        //     }
        // }
        // var ldh = new Star("刘德华", 18, "男");
        // console.log(ldh["sex"]);
        // console.log(ldh.age);
        // console.log(typeof ldh);
        // console.log(ldh);
        // ldh.sing("冰雨");

        function Hero(name, blood, attack) {
            this.name = name;
            this.blood = blood;
            this.attack = attack;
            this.type = function(type) {
                console.log(type);
            }
        }
        var houyi = new Hero("后裔", 50, "射箭");
        // console.log(houyi);
        // houyi.type("射手");
        for (var k in houyi) {
            console.log(k); //变量输出 ，输出的是属性名
            console.log(houyi[k]); //得到属性值
        }
    </script>
</head>

<body>

</body>

</html>